home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / Utilities / Misc / GMS / GMSDev / Source / C / Fading / WhiteFade.c < prev   
Encoding:
C/C++ Source or Header  |  1997-12-16  |  1.6 KB  |  53 lines

  1. /* Dice: dcc -l0 -mD dpk.o WhiteFade.c -o WhiteFade
  2. **
  3. ** There are three examples of fading in this program:  ColourMorph(),
  4. ** ColourToPalette(), and PaletteToColour().  This demo will only work for
  5. ** pictures that make use of a palette table - ie it wouldn't work
  6. ** for a true colour screen.
  7. */
  8.  
  9. #include <proto/dpkernel.h>
  10.  
  11. BYTE *ProgName      = "White Fading Demo";
  12. BYTE *ProgAuthor    = "Paul Manias";
  13. BYTE *ProgDate      = "8 October 1997";
  14. BYTE *ProgCopyright = "DreamWorld Productions (c) 1996-1997.  Freely distributable.";
  15. BYTE *ProgShort     = "Demonstration of screen fading.";
  16.  
  17. void main(void)
  18. {
  19.   WORD FadeState = 0;
  20.   struct GScreen *screen;
  21.   struct Picture *pic;
  22.   struct FileName PicFile = { ID_FILENAME, "GMS:demos/data/PIC.Loading" };
  23.  
  24.   if (pic = Load(&PicFile, ID_PICTURE)) {
  25.    if (screen = Get(ID_SCREEN)) {
  26.       CopyStructure(pic,screen);
  27.       screen->MemPtr1 = pic->Bitmap->Data;
  28.       screen->Palette = NULL;
  29.       screen->Attrib  = BLANKPALETTE;
  30.  
  31.       if (screen = Init(screen,NULL)) {
  32.          Display(screen);
  33.  
  34.          do { WaitAVBL();
  35.               FadeState = ColourMorph(screen,FadeState,10,0,screen->Bitmap->AmtColours,0x000000,0xFFFFFF);
  36.          } while (FadeState != NULL);
  37.  
  38.          do { WaitAVBL();
  39.               FadeState = ColourToPalette(screen,FadeState,2,0,screen->Bitmap->AmtColours,pic->Palette+2,0xFFFFFF);
  40.          } while (FadeState != NULL);
  41.  
  42.          do { WaitAVBL();
  43.               FadeState = PaletteToColour(screen,FadeState,2,0,screen->Bitmap->AmtColours,pic->Palette+2,0x000000);
  44.          } while (FadeState != NULL);
  45.  
  46.       }
  47.    Free(screen);
  48.    }
  49.   Free(pic);
  50.   }
  51. }
  52.  
  53.